package com.handinglian.task.enums;

public enum PhoneStateEnum {
    CALL_FAILURE(0,"呼叫失败"),
    NOT_ANSWER(1,"无应答"),
    ANSWER(2,"已应答");

    public static PhoneStateEnum valueOfOrdinal(Integer ordinal) {
        return ordinal == null || ordinal >= values().length ? null : values()[ordinal];
    }
    public static PhoneStateEnum valueOfDesc(String desc) {
        for(PhoneStateEnum phoneStateEnum: PhoneStateEnum.values()){
            if(desc.equals(phoneStateEnum.getDescription())){
                return phoneStateEnum;
            }
        }
        return null;
    }
    public static PhoneStateEnum valueOfKey(Integer key){
        for(PhoneStateEnum phoneStateEnum : PhoneStateEnum.values()){
            if(phoneStateEnum .getKey()==key){
                return phoneStateEnum;
            }
        }
        return null;
    }
    private final Integer key;
    private final String description;

    PhoneStateEnum(Integer key, String description) {
        this.key = key;
        this.description = description;
    }

    public Integer getKey() {
        return key;
    }
    public String getDescription() {
        return this.description;
    }
}
